home *** CD-ROM | disk | FTP | other *** search
- N KEYCODE.COM
- A 100
- JMP 0126
- DB " = "
- DB " hex "
- DB " "
- DB " decimal",0D,0A,24
- MOV AH, 00 ;for extended keyboard, change to MOV AH, 10
- INT 16 ;return scan code AH, ascii in AL
- MOV BX, AX ;store in BX. BX is uneffected by
- MOV DL, AL ; hexidecimal or decimal routine
- MOV AH, 02
- INT 21 ;see if ascii printable character
- MOV DI, 0106 ;pointer to start of hex template
- CALL 0151 ;call hexadecimal routine
- MOV AL, BL ;ascii value in AL
- MOV DI, 011A
- CALL 0170 ;call decimal routine
- MOV AL, BH ;scan value in AL
- MOV DI, 0116
- CALL 0170 ;call decimal routine
- MOV DX, 0102 ;display all values
- MOV AH, 09
- INT 21
- JMP 0126 ;go again. Quit with Ctrl-Break
- MOV CX, 0404 ;HEXIDECIMAL: counter in CH, rotate value in CL
- ROL BX, CL ;get digit in BL. (Note that 4 rotations
- MOV AL, BL ; will leave BX unchanged, when done.)
- AND AL, 0F ;zero high bits--do one number at a time
- OR AL, 30 ;add 30h, makes display-able ascii value
- CMP AL, 3A ;digit 0-9 if below
- JL 0162 ;jump to SHOW
- ADD AL, 07 ;else make letter A-F
- MOV [DI], AL ;place with DI pointer
- INC DI ;next position right
- CMP CH, 03 ;have we got end of scan code?
- JNZ 016B
- INC DI ; if so, then leave one space
- DEC CH ;decrease counter
- JNZ 0154 ;if counter not zero, go again
- RET
- MOV CX, 030A ;DECIMAL: counter in CH, divisor in CL
- XOR AH, AH ;zero AH
- DIV CL ;divide AL by 0A (10 d), remainder in AH
- OR AH, 30 ;make AH a display-able ascii value
- MOV [DI], AH ;and place with pointer
- DEC DI ;move one posiiton left
- DEC CH ;decrease counter
- JZ 018A ;if counter zero, jump to return
- CMP AL, 00 ;still a numerator to work with?
- JNZ 0173 ; if so, go again
- MOV BYTE PTR [DI], 20 ;fill out three digits with blanks
- JMP 017C ; if necessary, to clear work area
- RET
-
- R CX
- 8B
- W
- Q